//
//  WDTaskDetailBasicSingleView.m
//  wd-serviceapp
//
//  Created by Bin Tang on 2024/8/29.
//

#import "WDTaskDetailBasicSingleView.h"

@interface WDTaskDetailBasicSingleView ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *valueLabel;

@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *value;
@property (nonatomic, assign) float valueHeight;


- (void)initWithTitleLabel;

- (void)initWithValueLabel;

@end

@implementation WDTaskDetailBasicSingleView

- (void)initWithSubView {
    [super initWithSubView];
    
    
}

- (void)initWithTitleLabel {
    if (!_titleLabel) {
        CGRect frame = CGRectMake(20, 10, 102, 18);
        _titleLabel = [UILabel createWithLabel:self frame:frame font:[UIFont systemFontOfSize:13 weight:UIFontWeightRegular] propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#333333"];
        }];
    }
    self.titleLabel.text = objectNull(self.title);
}

- (void)initWithValueLabel {
    if (!_valueLabel) {
        CGRect frame = self.titleLabel.frame;
        frame.origin.x = self.titleLabel.right;
        frame.size.width = self.width - self.titleLabel.right - 20;
        _valueLabel = [UILabel createWithLabel:self frame:frame font:[UIFont systemFontOfSize:13 weight:UIFontWeightRegular] propertiesBlock:^(UILabel * _Nonnull label) {
            label.textColor = [UIColor colorWithHexString:@"#333333"];
            label.numberOfLines = 0;
        }];
    }
    _valueLabel.height = self.valueHeight;
    _valueLabel.text = objectNull(self.value);
}

- (void)setValueColor:(UIColor *)valueColor {
    _valueLabel.textColor = valueColor;
}

- (void)updateWithViewTitle:(NSString *)title value:(NSString *)value valueHeight:(float)valueHeight {
    self.title = title;
    self.value = value;
    self.valueHeight = valueHeight;
    
    [self initWithTitleLabel];

    [self initWithValueLabel];
}

@end
